using System;
namespace fuzzyKittenVNC
{
	public class VNCSecurityHandler
	{
		public static int[] secTypeOrder = {1,2};
		private VNCSecurityHandler () {}
		
		public static VNCSecurity.SecImplementation getSecurityHandler(Int32 secNr) {
			switch(secNr) {
				case 1: 
					return new fuzzyKittenVNC.VNCSecurity.SecNone();
				case 2: 
					return new fuzzyKittenVNC.VNCSecurity.SecVNCAuthentification();
				default:
					return null;
			}
		}
		
		public static VNCSecurity.SecImplementation getPreferredImplementation(Int32[] available) {
			foreach(Int32 preferredType in VNCSecurityHandler.secTypeOrder) {
				foreach(Int32 currentNr in available) {
					if(currentNr == preferredType)
						return VNCSecurityHandler.getSecurityHandler(currentNr);
					
				}	
			}
			return null;
		}
		
	}
}